//
//  ExhibitWorkDetailsTopTableCell.m
//  ArtDog
//
//  Created by dllo on 16/9/20.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ExhibitWorkDetailsTopTableCell.h"
#import "ExhibitWorkDetailsMainModel.h"
#import "ExhibitWorkUserModel.h"
#import "UIImageView+WebCache.h"

@interface ExhibitWorkDetailsTopTableCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (weak, nonatomic) IBOutlet UILabel *autorLabel;
@property (weak, nonatomic) IBOutlet UILabel *sizeLabel;
@property (weak, nonatomic) IBOutlet UILabel *yearLabel;

@property (weak, nonatomic) IBOutlet UILabel *praiseLabel;
@property (weak, nonatomic) IBOutlet UIImageView *loveImage;
@property (weak, nonatomic) IBOutlet UIImageView *praiseImageOne;
@property (weak, nonatomic) IBOutlet UIImageView *praiseImageTwo;
@property (weak, nonatomic) IBOutlet UIImageView *praiseImageThree;

@end

@implementation ExhibitWorkDetailsTopTableCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setDetailsModel:(ExhibitWorkDetailsMainModel *)detailsModel
{
    _detailsModel = detailsModel;
    _nameLabel.text = detailsModel.workName;
    _autorLabel.text = detailsModel.author;
    _sizeLabel.text = detailsModel.worksSize;
    _yearLabel.text = detailsModel.worksYears;
    _praiseLabel.text = [NSString stringWithFormat:@"%@", detailsModel.praiseCount];
    if (detailsModel.praiseUsers != nil && detailsModel.praiseUsers.count != 0) {
        _praiseImageOne.hidden = NO;
        NSInteger index = 0;
        for (ExhibitWorkUserModel *userModel in detailsModel.praiseUsers) {
            if (index == 0) {
                [_praiseImageOne sd_setImageWithURL:[NSURL URLWithString:userModel.headPic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
            } else if (index == 1) {
                _praiseImageTwo.hidden = NO;
                [_praiseImageTwo sd_setImageWithURL:[NSURL URLWithString:userModel.headPic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
            } else if (index == 2) {
                _praiseImageThree.hidden = NO;
                [_praiseImageThree sd_setImageWithURL:[NSURL URLWithString:userModel.headPic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
            } else {
                break;
            }
            index++;
        }
    } else {
        _praiseImageThree.hidden = YES;
        _praiseImageTwo.hidden = YES;
        _praiseImageOne.hidden = YES;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
